#include <iostream>
#include <string>
#include <ctime>
#include <unistd.h>
#include <pthread.h>

using namespace std;

void *threadRun(void *arg)
{
    int n = 3;
    while(n)
    {
        cout << "次线程 " << n-- << endl;
        sleep(1);
    }
}

int main()
{
    pthread_t t;
    pthread_create(&t, nullptr, threadRun, nullptr);

    pthread_detach(t);

    int n = 5;
    while(n)
    {
        cout << "主线程 " << n-- << endl;
        sleep(1);
    }


    return 0;
}

